home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qlayout.h.z / qlayout.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  4.8 KB  |  199 lines

  1. /****************************************************************************
  2. ** $Id: qlayout.h,v 2.19 1998/07/03 00:09:34 hanord Exp $
  3. **
  4. ** Definition of layout classes
  5. **
  6. ** Created : 960416
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QLAYOUT_H
  25. #define QLAYOUT_H
  26.  
  27. #ifndef QT_H
  28. #include "qgmanager.h"
  29. #include "qlist.h"
  30. #endif // QT_H
  31.  
  32. class QMenuBar;
  33.  
  34. struct QLayoutData;
  35.  
  36.  
  37. class QLayout : public QObject
  38. {
  39.     Q_OBJECT
  40. public:
  41.     virtual ~QLayout();
  42.     int defaultBorder() const { return defBorder; }
  43.  
  44.     enum { unlimited = QCOORD_MAX };
  45.  
  46.     virtual bool activate();
  47.     void freeze( int w, int h );
  48.     void freeze() { freeze( 0, 0 ); }
  49.  
  50.     void  setMenuBar( QMenuBar *w );
  51.  
  52.     QWidget *mainWidget();
  53.  
  54. protected:
  55.     QLayout( QWidget *parent,  int border,
  56.          int autoBorder, const char *name );
  57.     QLayout( int autoBorder = -1, const char *name=0 );
  58.  
  59.     QGManager *basicManager() { return bm; }
  60.     virtual QChain *mainVerticalChain() = 0;
  61.     virtual QChain *mainHorizontalChain() = 0;
  62.  
  63.     virtual void initGM() = 0;
  64.     void addChildLayout( QLayout *);
  65.  
  66.     static QChain *verChain( QLayout *l ) { return l->mainVerticalChain(); }
  67.     static QChain *horChain( QLayout *l ) { return l->mainHorizontalChain(); }
  68.  
  69. private:
  70.     QGManager * bm;
  71.     int defBorder;
  72.     bool    topLevel;
  73.  
  74.     QLayoutData *extraData;
  75. private:    // Disabled copy constructor and operator=
  76.     QLayout( const QLayout & );
  77.     QLayout &operator=( const QLayout & );
  78.  
  79. };
  80.  
  81.  
  82. class QBoxLayout : public QLayout
  83. {
  84.     Q_OBJECT
  85. public:
  86.     enum Direction { LeftToRight, RightToLeft, TopToBottom, BottomToTop,
  87.              Down = TopToBottom, Up = BottomToTop };
  88.  
  89.     QBoxLayout( QWidget *parent, Direction, int border=0,
  90.         int autoBorder = -1, const char *name=0 );
  91.  
  92.     QBoxLayout(    Direction, int autoBorder = -1,
  93.         const char *name=0 );
  94.  
  95.     ~QBoxLayout();
  96.  
  97.     void addSpacing( int size );
  98.     void addStretch( int stretch = 0 );
  99.     void addWidget( QWidget *, int stretch = 0, int alignment = AlignCenter );
  100.     void addLayout( QLayout *layout, int stretch = 0 );
  101.     Direction direction() const { return (Direction)dir; }
  102.  
  103.     void addStrut( int );
  104. protected:
  105.     QChain *mainVerticalChain();
  106.     QChain *mainHorizontalChain();
  107.     void initGM();
  108.  
  109. private:
  110.     void addB( QLayout *, int stretch );
  111.  
  112.     QGManager::Direction dir;
  113.     QChain * parChain;
  114.     QChain * serChain;
  115.     bool    pristine;
  116.  
  117. private:    // Disabled copy constructor and operator=
  118.     QBoxLayout( const QBoxLayout & );
  119.     QBoxLayout &operator=( const QBoxLayout & );
  120.  
  121. };
  122.  
  123.  
  124. class QHBoxLayout : public QBoxLayout
  125. {
  126.     Q_OBJECT
  127. public:
  128.     QHBoxLayout( QWidget *parent, int border=0,
  129.         int autoBorder = -1, const char *name=0 );
  130.  
  131.     QHBoxLayout( int autoBorder = -1, const char *name=0 );
  132.  
  133.     ~QHBoxLayout();
  134. };
  135.  
  136.  
  137.  
  138. class QVBoxLayout : public QBoxLayout
  139. {
  140.     Q_OBJECT
  141. public:
  142.     QVBoxLayout( QWidget *parent, int border=0,
  143.         int autoBorder = -1, const char *name=0 );
  144.  
  145.     QVBoxLayout( int autoBorder = -1, const char *name=0 );
  146.  
  147.     ~QVBoxLayout();
  148. };
  149.  
  150.  
  151.  
  152. class QGridLayout : public QLayout
  153. {
  154.     Q_OBJECT
  155. public:
  156.     QGridLayout( QWidget *parent, int nRows, int nCols, int border=0,
  157.          int autoBorder = -1, const char *name=0 );
  158.     QGridLayout( int nRows, int nCols, int autoBorder = -1,
  159.          const char *name=0 );
  160.     ~QGridLayout();
  161.     void addWidget( QWidget *, int row, int col, int align = 0 );
  162.     void addMultiCellWidget( QWidget *, int fromRow, int toRow,
  163.                    int fromCol, int toCol, int align = 0 );
  164.     void addLayout( QLayout *layout, int row, int col);
  165.  
  166.     void setRowStretch( int row, int stretch );
  167.     void setColStretch( int col, int stretch );
  168.     void addRowSpacing( int row, int minsize );
  169.     void addColSpacing( int col, int minsize );
  170.  
  171.     int numRows() const { return rr; }
  172.     int numCols() const { return cc; }
  173.  
  174.     void expand( int rows, int cols );
  175.  
  176. protected:
  177.     QChain *mainVerticalChain() { return verChain; }
  178.     QChain *mainHorizontalChain() { return horChain; }
  179.     void initGM();
  180.  
  181. private:
  182.     QArray<QChain*> *rows;
  183.     QArray<QChain*> *cols;
  184.  
  185.     QChain *horChain;
  186.     QChain *verChain;
  187.     void init ( int r, int c );
  188.  
  189.     int rr;
  190.     int cc;
  191.  
  192. private:    // Disabled copy constructor and operator=
  193.     QGridLayout( const QGridLayout & );
  194.     QGridLayout &operator=( const QGridLayout & );
  195. };
  196.  
  197.  
  198. #endif // QLAYOUT_H
  199.